package com.lzh.webSocket.domain.vo.req;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum WSReqTypeEnum {
    LOGIN(1, "登录请求"),

    HEART_BEAT(2, "心跳包"),

    SEND_MESSAGE(3, "登录认证");

    public final int type;
    public final String desc;


    private static Map<Integer, WSReqTypeEnum> cache;

    static {
        cache = Arrays.stream(WSReqTypeEnum.values()).collect(Collectors.toMap(WSReqTypeEnum::getType, Function.identity()));
    }

    public static WSReqTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
